<!DOCTYPE html>
<html>
	<head>
		<title>Home</title>
		<!--bootstarp-css-->
		<link href="../css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
		<!--/bootstarp-css -->
		<!--css-->
		<link rel="stylesheet" href="../css/style.css" type="text/css" media="all" />
		<link href="../css/hover.css" rel="stylesheet" media="all">
		<link rel="stylesheet" href="../css/adoptPost.css" type="text/css" media="all" />
		<script src="../js/my-app.js"></script>
		<style>
			.wd_cx_box {
				background: #f1f2f4;
			}

			.wd_p_cart {
				position: static;
				margin: 15px 0px 15px 360px;
				padding-top: 7px;
				height: 60px;
				max-width: 640px;
				border-top: 1px solid #ddd;
				background-color: #fefefe;
			}

			.ichcek_bg {
				line-height: 30px;
				padding-left: 0;
			}

			.ichcek_bg .icheckbox_square-orange,
			.ichcek_bg .iradio_square-orange {
				margin-right: 10px;
				height: 25px;
				;
			}

			.service_container {
				margin-top: 1px;
			}

			.shop_well {
				padding: 10px;
				border: none;
				border-bottom: 2px solid #f1f2f4;
				background: #fff;
				border-radius: 0
			}

			#jiyang-order-form .control-label {
				font-weight: normal !important;
				color: #999 !important;
				font-style: normal;
			}

			.jiamubiao .table>tbody>tr>td {
				text-align: center;
			}

			.kalendae .k-caption {
				color: #999 !important;
				font-size: 18px;
			}

			.kalendae .k-title {
				margin-bottom: 5px !important;
			}

			.kalendae .k-btn-next-month,
			.kalendae .k-btn-previous-month {
				font-size: 30px;
			}

			.kalendae .k-header span {
				font-weight: normal;
			}

			.jiamu-cell-box {
				width: 25%;
				float: left;
				text-align: center;
			}

			.jiamu-cell {
				margin: 10px auto;
				border: none;
				font-size: 14px;
			}

			.jiamu-container {
				padding: 0;
				border-bottom: 1px solid #f4f4f4;
				clear: both;
			}

			.kalendae .k-title {
				height: 35px;
				line-height: 35px;
			}

			.kalendae .k-days span,
			.kalendae .k-header span {
				height: 40px;
				line-height: 40px;
			}

			#select-date-range {
				margin-top: 10px;
				padding: 5px 0;
				border-color: #ddd;
				border-style: solid none;
				border-width: 1px medium;
				border-image: none;
				font-size: 14px;
				-moz-border-bottom-colors: none;
				-moz-border-left-colors: none;
				-moz-border-right-colors: none;
				-moz-border-top-colors: none;
			}

			.weui_dialog {
				display: none;
				border: 1px solid #0c8687;
				position: fixed;
				top: 35%;
				left: 32.5%;
				width: 35%;
				background-color: #FAFAFC;
				border-radius: 3px;
				z-index: 9999;
				/* opacity: 1;
				visibility: visible; */
				display: 1;
				transform: scale(1);
			}

			.weui_dialog_hd {
				padding: 1.2em 0 .5em;
				text-align: center;
			}

			.weui_dialog_bd {
				padding: 0 20px;
				font-size: 15px;
				color: #888;
				text-align: center;
			}

			.weui_dialog_ft {
				position: relative;
				line-height: 42px;
				margin-top: 20px;
				font-size: 17px;
				display: -webkit-box;
				display: -webkit-flex;
				display: -ms-flexbox;
				display: flex;
			}

			.weui_dialog_ft a {
				display: block;
				-webkit-box-flex: 1;
				-webkit-flex: 1;
				-ms-flex: 1;
				flex: 1;
				color: #0c8687;
				text-align: center;
			}

			.weui_btn_dialog.default {
				color: #353535;
			}

			#backdrop {
				width: 100%;
				height: 100%;
				visibility: hidden;
				/* visible hidden; */
				opacity: 0;
				/*1  0*/
				position: fixed;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
				background: rgba(8, 7, 7, 0.6);
				z-index: 100;
				transition: all .2s ease;
				backdrop-filter: saturate(180%) blur(1px);
				/* $("#backdrop").css("visibility", "hidden");
				$("#backdrop").css("opacity", "0"); */
			}

			#yincan {
				width: 160px;
				height: 110px;
				position: absolute;
				top: 70px;
				right: 46px;
				background-color: #fff;
				display: none;
			}

			/* 日历 */
			.calendar {
				width: 700px;
				height: 350px;
				background: #fff;
				box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.1);
				margin: 10px auto 0;
			}

			.title2 {
				width: 100%;
				height: 64px;
				/* border: 1px #000 solid; */
				margin: 0 auto;
				font-size: 20px;
				text-align: center;
				line-height: 65px;
			}

			#prev {
				float: left;
				font-size: 36px;
				color: #0c8687;
			}

			#next {
				float: right;
				font-size: 36px;
				color: #0c8687;
			}

			.body-list ul {
				width: 100%;
				font-family: arial;
				font-weight: bold;
				font-size: 18px;
			}

			.body-list ul li {
				width: 14.28%;
				height: 36px;
				line-height: 36px;
				list-style-type: none;
				display: block;
				box-sizing: border-box;
				float: left;
				text-align: center;
			}

			.lightgrey {
				color: #a8a8a8;
				/*浅灰色*/
			}

			.darkgrey {
				color: #565656;
				/*深灰色*/
			}

			.green {
				color: #fff;
				/*绿色*/
			}

			.green2 {
				color: #0c8687;
				/*绿色*/
			}

			.red {
				color: red;
			}

			.greenbox {
				/* border: 1px solid #6ac13c;
				background: #e9f8df; */
				background: #0c8687cf;
				/*浅绿色背景*/
			}
		</style>
		<!--/css-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="keywords" content="Petcare Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, 
Smartphone Compatible web template, free web designs for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
		<script type="application/x-javascript">
			addEventListener("load", function() {
				setTimeout(hideURLbar, 0);
			}, false);

			function hideURLbar() {
				window.scrollTo(0, 1);
			}
		</script>

		<script src="../js/jquery.min.js"></script>
		<script src="../js/modernizr.custom.js"></script>
		<script src="../js/responsiveslides.min.js"></script>
		<script src="../js/bootstrap.min.js"></script>
		<script src="../js/jquery-3.2.1.min.js"></script>
		<script type="text/javascript"
			src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=SgoW5AbGKRdxnBga6gmIVWQZYXquhuSE"></script>
	</head>
	<body id="box1">
		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
			aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="messagetitle" data-toggle="modal" data-target="#messageBox">订单信息
						</h4>
					</div>
					<div class="modal-body">
						<div class="tab-block">
							<table class="table" style="margin-bottom: 0">
								<tbody>
									<tr>
										<td>下单店铺:<span class="pull-right psaddress">小八宠物店</span></td>
									</tr>
									<tr>
										<td>店铺地址:<span class="pull-right" style="color: red;"><a
													href="javascript:void(0)" id="baidumap"
													style="color:#0c8687;">北京市海淀区西三旗金燕龙大厦</a></span></td>
									</tr>
									<tr>
										<td>订单号:<span class="pull-right" id="ordernum">230825395000416</span></td>
									</tr>
									<tr>
										<td>支付方式:<span class="pull-right">支付宝</span></td>
									</tr>
									<tr>
										<td>支付状态:<span class="pull-right" style="color: red;">未支付</span></td>
									</tr>
									<tr>
										<td>下单时间:<span class="pull-right">刚刚</span></td>
									</tr>
									<tr>
										<style>
											.khxx {
												border: 1px #ccc solid;
												width: 100%;
												height: 60px;
												font-size: 13px;
												margin: 5px;
											}
										</style>
										<td>客户信息:
											<table border="1" class="khxx">
												<tr>
													<td>客户：</td>
													<td class="text-right lxr">柠檬</td>
												</tr>
												<tr>
													<td>手机号：</td>
													<td class="text-right lxdh">17365765467</td>
												</tr>
											</table>
										</td>

									</tr>
									<tr>
										<td class="petinfoshow">宠物信息：
											<style>
												.petinfo span {
													font-size: 13px;
													margin: 0 5px;
												}
											</style>
											<!-- <p>
											<div class="media">
												<div class="media-left" style="float: left;">
													<a href="javascript:;">
														<img class="thumbnail media-object" style="width: 50px;"
															src="http://i1.bagong.cn/9d/d6/2d81c6eb442c247c7248bf1b0f79_100x100_1.jpg"
															alt="柠檬">
													</a>
												</div>
												<div class="petinfo" style="float: left;">
													<p><span>柠檬</span><small
															class="text-info">母</small><span>(雪鞋猫)</span></p>
													<p><span class="price_class">生日：<span>2023-08-25</span></span></p>
												</div>
											</div>
											</p>	 -->
										</td>
									</tr>
									<tr>
										<td>支付项目:
											<p>
											<div class="media">
												<a class="thumbnail pull-left" style="padding-right: 4px;">
													<img class="media-object service_img"
														src="https://www.bagong.cn/jic/i/service_icon/jiyang.png"
														width="50px">
												</a>
												<div>
													<style>
														#itemname:hover {
															color: #0c8687;
															text-decoration: none;
														}
													</style>
													<a href="" id="itemname"
														style="margin-left: 10px;color: #0c8687;">为2只宠物申请的豪华间寄养服务</a>
													<p><span class="price_class red" style="margin-left: 10px;">
															￥1520 </span></p>
												</div>
											</div>
											<div class="text-right price_param">
												<h5>合计：￥<span class="price_class red">1520</span></h5>
												<h5 class="">应付金额：￥<span class="price_class red">1520</span></h5>
											</div>
											</p>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="modal-footer">
						<button type="submit" class="btn btn-success" style="width: 100px;height: 40px;outline: none;" id="zhifu">支付</button>
						<button type="button" class="btn btn-danger"
							style="margin-right: 20px;width: 100px;height: 40px;outline: none;"
							data-dismiss="modal">关闭</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal -->
		</div>

		<div id="backdrop"></div>
		<!--header-->
		<div class="header">
			<div class="header-info">
				<div class="container">
					<div class="logo">
						<a href="index.html"><img src="../images/logo-pet.png" style="position: absolute;width: 330px;height: 262px;top: -60px;left: 280px;"/></a>
					</div>
					<div class="search-box">
						<form>
							<input type="text" name="s" class="textbox" placeholder="Search" required="">
							<input type="submit" value="">
						</form>
					</div>
					<div class="clearfix"> </div>
				</div>
			</div>
		</div>
		<div class="container">
			<div class="header-bottom">
				<div class="menu">
					<span class="menu-info"> </span>
					<ul class="cl-effect-21">
						<li id="oneser"><a id="service" href="index.html" class="active">服务中心</a>
							<div id="yican">
								<div>
									<p><a href="adopt.html">宠物领养</a></p>
									<p><a href="farmed.html">宠物寄养</a></p>
									<p><a href="notice.html">寻宠|招领</a></p>
								</div>
							</div>
						</li>
						<li><a href="petbaike.html">宠物百科</a></li>
						<li><a href="news.html">宠物新闻</a></li>
						<li><a href="bbs.html">宠物论坛</a></li>
						<li><a>关于我们</a></li>
						<li id="twoser">
							<a id="myme">个人中心</a>
							<div id="yincan">
								<div>
									<p><a href="myinfo.html">我的</a></p>
									<p><a id="overpet">注销</a></p>
								</div>
							</div>
						</li>
					</ul>
				</div>
				<div class="clearfix"> </div>
			</div>
		</div>

		<div class="mobile-container" style="margin: 0 auto;width: 970px;margin-top: 60px;">
			<div class="row">
				<div class="tab-block tab-content service_container">
					<span class="label label-warning hidden-xs" style="float: right;margin-right: 70px;">选择寄养</span>
					<form class="form-wrapper productDescription noajax" name="save-jiyang-order">
						<div id="jiyang-order-form" class="order-form-box">
							<div class="row">
								<input type="hidden" name="type" value="jiyang">

								<div class="col-xs-12  input-cell">
									<div class="calendar">
										<div class="title">
											<div class="title2">
												<a href="" id="prev">«</a>
												<span>
													<span class="green2" id="calendar-title"></span>
													<span class="green2">,</span>
													<span class="green2" id="calendar-year"></span>
												</span>
												<a href="" id="next">»</a>
											</div>
										</div>
										<div class="body">
											<div class="lightgrey body-list">
												<ul>
													<li>周一</li>
													<li>周二</li>
													<li>周三</li>
													<li>周四</li>
													<li>周五</li>
													<li>周六</li>
													<li>周日</li>
												</ul>
											</div>
											<div class="darkgrey body-list">
												<ul id="days">
												</ul>
											</div>
										</div>
									</div>
									<div id="select-date-range">
										<em class="control-label">寄养日期：</em>
										<span class="today red"></span>
										<span>至</span>
										<span id="jiyangtianshu" class="red"></span>
										(<span id="dd" class="red">0</span>天)
									</div>
									<input type="hidden" name="order_date_start" id="date_start" value="">
									<input type="hidden" name="order_date_end" id="date_end" value="">
								</div>
								<div class="col-xs-12 input-cell">
									<label class="control-label">选择待寄养的宠物(数量：<span id="petnum" class="red">0</span>
										只)</label>
									<div id="MyPet">
										<ul class="list-inline list-unstyled" style="margin-bottom: 0">
											<li class="pet_cell_select" title="柠檬">
												<input type="checkbox" name="pets" />
												<label class="" for="pet_10567198">柠檬</label>
											</li>
										</ul>
									</div>
								</div>
								<!-- /店铺项目 -->
								<div class="col-md-6 col-xs-12 input-cell" id="dog_size_box">
									<label class="control-label">项目 <small>（价格仅供参考，以线下实际收取金额为准）</small></label>
									<select name="item_id" disabled class="form-control selectpicker item_select">
										<option>服务暂未开通</option>
										<option>全身spa 480一位</option>
										<option>日常生活 600一位</option>
										<option>喵喵spa 800一位</option>
									</select>
								</div>
								<!-- /联系人 -->
								<div class="col-md-6 col-xs-12 input-cell">
									<label class="control-label">联系人</label>
									<input type="text" value="" class="form-control order_input" name="contacts"
										placeholder="姓名">
								</div>
								<!-- /手机号-->
								<div class="col-md-6 col-xs-12 input-cell">
									<label class="control-label">手机号</label>
									<input type="text" value="" class="form-control order_input" style="width: 200px;"
										name="contact_tel" placeholder="输入手机号">
								</div>
								<!-- /备注 -->
								<div class="col-md-12 col-xs-12 input-cell">
									<label class="control-label">备注</label>
									<textarea rows="4" class="form-control" id="bz" name="order_message"
										placeholder="如：金毛3岁，饮食习惯"></textarea>
								</div>
								<input id="psid" type="hidden" />
								<input id="price" type="hidden" />
							</div><!-- /.row -->
						</div>
					</form>
				</div>
				<div class="wd_p_cart">
					<div class="col-xs-2">
						<div class="icon_wrap_i text-center" style="margin-left: 230px;">
							<div style="line-height: 45px" class="red">
								￥<span id="order_account" class="price_class red"></span>.00
							</div>
						</div>
					</div>
					<div class="col-xs-10" style="width: 25.333333%;">
						<div class="row buy_btn_group" style="margin-left: 235px;">
							
							<div class="col-xs-6" style="width: 300px;">	
							<button class="btn btn-success btn-sm yzaddorder" style="float: left;outline: none;margin-top: 10px;">验证</button>
								<button data-toggle="modal" data-target="#myModal" type="submit" onclick="dz()"
									class="btn btn-success btn-block btn-lg addorder" disabled style="outline: none;width:80%;float: right;"><i
										class="fa fa-flash"></i> &nbsp;生成订单</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>


		<!--/header-->

		<!--footer-->
		<div class="footer">
			<div class="container">
				<div class="copy-rights">
					<p>Copyright &copy; 2023.Company <a target="_blank" href="index.html">you宠</a></p>
				</div>

			</div>
		</div>
		<!--/footer-->
		<div class="weui_dialog weui_dialog_visible">
			<div class="weui_dialog_hd"><strong class="weui_dialog_title">添加爱宠提示</strong></div>
			<div class="weui_dialog_bd">系统检测到您尚未添加您的爱宠</div>
			<div class="weui_dialog_ft">
				<a href="javascript:void(0);" class="weui_btn_dialog default1">暂不添加</a>
				<a href="addPet.html" class="weui_btn_dialog " >立即添加</a>		
			</div>
		</div>


		<!-- 日历显示 -->
		<script type="text/javascript">
			$(function() {
				var month_olympic = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
				var month_normal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
				// var month_name = ["January", "Febrary", "March", "April", "May", "June", "July", "Auguest",
				// 	"September", "October", "November", "December"
				// ];
				var month_name = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月",
					"九月", "十月", "十一月", "十二月"
				];
				var holder = document.getElementById("days");
				var prev = document.getElementById("prev");
				var next = document.getElementById("next");
				var ctitle = document.getElementById("calendar-title");
				var cyear = document.getElementById("calendar-year");
				var my_date = new Date();
				var my_year = my_date.getFullYear();
				var my_month = my_date.getMonth();
				var my_day = my_date.getDate();

				var mm = "";
				var dd = "";
				if (my_month + 1 < 10) {
					mm = "0" + (my_month + 1);
				} else {
					mm = my_month + 1;
				}
				if (my_day < 10) {
					dd = "0" + my_day
				} else {
					dd = my_day;
				}

				$(".today").text(my_year + "-" + mm + "-" + dd);

				//获取某年某月第一天是星期几
				function dayStart(month, year) {
					var tmpDate = new Date(year, month, 1);
					return (tmpDate.getDay());
				}
				//计算某年是不是闰年，通过求年份除以4的余数即可
				function daysMonth(month, year) {
					var tmp = year % 4;
					if (tmp == 0) {
						return (month_olympic[month]);
					} else {
						return (month_normal[month]);
					}
				}
				//月份日期显示
				function refreshDate() {
					var str = "";
					var totalDay = daysMonth(my_month, my_year); //获取该月总天数
					var firstDay = dayStart(my_month, my_year); //获取该月第一天是星期几
					var myclass;
					var click;
					for (var i = 1; i < firstDay; i++) {
						str += "<li></li>"; //为起始日之前的日期创建空白节点
					}
					for (var i = 1; i <= totalDay; i++) {
						if ((i < my_day && my_year == my_date.getFullYear() && my_month == my_date.getMonth()) ||
							my_year < my_date.getFullYear() || (my_year == my_date.getFullYear() && my_month <
								my_date.getMonth())) {
							myclass = " class='lightgrey'"; //当该日期在今天之前时，以浅灰色字体显示
							click = "";
						} else if (i == my_day && my_year == my_date.getFullYear() && my_month == my_date
							.getMonth()) {
							myclass = " class='green greenbox greenbox1'"; //当天日期以绿色背景突出显示
							click = "onclick='info(" + i + "," + my_month + "," + my_year + ",$(this))'";
						} else {
							myclass = " class='darkgrey'"; //当该日期在今天之后时，以深灰字体显示
							click = "onclick='info(" + i + "," + my_month + "," + my_year + ",$(this))'";
						}
						str += "<li  days='" + i + "'  " + myclass + " " + click + ">" + i + "</li>"; //创建日期节点
					}
					holder.innerHTML = str; //设置日期显示
					ctitle.innerHTML = month_name[my_month]; //设置英文月份显示
					cyear.innerHTML = my_year; //设置年份显示
				}
				refreshDate(); //执行该函数
				//上个月
				prev.onclick = function(e) {
					e.preventDefault();
					my_month--;
					if (my_month < 0) {
						my_year--;
						my_month = 11;
					}
					refreshDate();
				}
				//下个月
				next.onclick = function(e) {
					e.preventDefault();
					my_month++;
					if (my_month > 11) {
						my_year++;
						my_month = 0;
					}
					refreshDate();
				}
			})
			//点击显示当前日期
			function info(d, m, y, that) {
				// alert(y+"年"+(m+1)+"月"+d+"日");
				let mon = "";
				let day = "";
				if (m + 1 < 10) {
					mon = "0" + (m + 1);
				} else {
					mon = m + 1;
				}
				if (d < 10) {
					day = "0" + d;
				} else {
					day = d;
				}
				let xzrq = y + "-" + mon + "-" + day; //选择日期
				$("#jiyangtianshu").text(xzrq);
				let today = $(".today").text(); //当天日期				
				/**
				 * 计算两个日期之间的天数
				 *  date1  开始日期 yyyy-MM-dd
				 *  date2  结束日期 yyyy-MM-dd
				 *  如果日期相同 返回一天 开始日期大于结束日期，返回0
				 */
				function getDaysBetween(date1, date2) {
					var startDate = Date.parse(date1);
					var endDate = Date.parse(date2);
					if (startDate > endDate) {
						return 0;
					}
					if (startDate == endDate) {
						return 0;
					}
					var days = (endDate - startDate) / (1 * 24 * 60 * 60 * 1000);
					return days;
				}
				let xc = getDaysBetween(today, xzrq);
				show(xc);

				function show(days) {
					$(".greenbox").nextAll().attr("class", "darkgrey").css("color", "#565656");
					if (days >= 1) {
						$("#dd").text(days);
						for (var i = 1; i <= days; i++) {
							$(".greenbox" + i + "").next().attr("class", "darkgrey greenbox greenbox" + (i + 1) + "").css(
								"color", "#fff");
						}
					} else {
						$("#dd").text(0);
						$("#jiyangtianshu").text("");
					}
					addinfo();
				}

			}
		</script>
		<!--yican -->
		<script>
			$("#service").mouseenter(function() {
				$("#yican").css("display", "block");
			});
			$("#oneser").mouseleave(function() {
				$("#yican").css("display", "none");
			});
			$("#myme").mouseenter(function() {
				$("#yincan").css("display", "block");
			});
			$("#twoser").mouseleave(function() {
				$("#yincan").css("display", "none");
			});
			//注销
			$("#overpet").click(function() {
				if (!confirm('是否确定注销该用户并退出登录？'))
					return;
				$.post('http://localhost:80/ct/remove', function(res) {
					if (res) {
						location.href = 'login.html';
					}
				});
			})
		</script>
		<!-- /yican -->
		<!--script-nav -->
		<script>
			$("span.menu-info").click(function() {
				$("ul.cl-effect-21").slideToggle("slow", function() {});
			});
			//暂不添加
			$(".default1").click(function(){
				$(".weui_dialog").css("display", "none");
				$("#backdrop").css("visibility", "hidden");
				$("#backdrop").css("opacity", "0");
			})
		</script>
		<!-- /script-nav -->
		<script type="text/javascript">
			//自定义promise方法
			function getPromise(url, data) {
				return new Promise(function(resolve, reject) {
					$.post(url, data, function(res) {
						resolve(res);
					}, "json").fail(function(err) {
						reject(err);
					})
				});
			}
			$(function() {
				let temp = new URLSearchParams(location.search);
				let psid = temp.get("psid"); //店铺编号	
				let price = temp.get("price"); //寄养价格
				$("#psid").val(psid);
				$("#price").val(price);
				
				//验证我是否有宠物
				yzcw();
				function yzcw() {
					$.post('http://localhost:80/ct/mypetinfo2', {
						"status": 0
					}, function(r) {
						$(".list-unstyled").children().remove();
						if (r.records.length == 0) {
							$(".weui_dialog").css("display", "block");
							$("#backdrop").css("visibility", "visible");
							$("#backdrop").css("opacity", "1");
							let lis = "<a href='addPet.html' class='btn btn-success' style='outline: none;'>添加宠物</a>";
							$(".list-unstyled").append(lis);				
						}else{
							$(r.records).each(function(i, e) {
								let lis = "<li class='pet_cell_select' title='" + e.upname + "'>" +
									"<input type='checkbox' value='" + e.upid +
									"' name='pets' onchange='choosepet($(this))'/>" +
									"<label class='' for=''>" + e.upname + "</label>" +
									"</li>";
								$(".list-unstyled").append(lis);
							});
						}
					});
				}

				//加载用户信息
				userinfo();

				function userinfo() {
					$.post('http://localhost:80/ct/userdetail', {
						"uid": 0
					}, function(r) {
						$("input[name=contacts]").val(r.username);
						$("input[name=contact_tel]").val(r.phone);
					});
				}

				//加载添加信息
				addinfo();
				
				//点击支付
				$("#zhifu").click(function(){
					let orderid =$("#ordernum").text();//订单号
					let moneys = $("#order_account").text(); //总金额
					let remark = $("#bz").val(); //备注
					let oname =$("#itemname").text();//订单名称
					$.post('http://localhost:80/ct/pay',{"orderid":orderid,"moneys":moneys,"remark":remark,"oname":oname},function(res){
						console.log(res);
						$('#box1').prepend(res);	
					},"text");
				})
			  
			    //验证是否可以生成订单
			    $(".yzaddorder").click(function(){
				let num =$("#petnum").text();//宠物数量
				let days =$("#dd").text();//寄养天数
				if(num != 0 && days != 0){
					alert("验证通过，可以生成订单！");
					$(".addorder").removeAttr("disabled");
					// $(".yzaddorder").text("√");
				}else{				
					if(num == 0){
						alert("您未选择寄养宠物！");
						return;
					}
					if(days == 0){
						alert("您未选择寄养天数！");
						return;
					}
				}				
				})
			})


			let upids;
			//选择宠物添加至数组 数量改变
			function choosepet() {
				//用来存储宠物id
				upids = new Array();
				//循环所有选中的值
				$('input[name=pets]:checked').each(function(i, e) {
					//追加到数组中
					upids.push($(e).val());
				});
				$("#petnum").text(upids.length);
				addinfo();
			}

			function addinfo() {
				let jg = $("#price").val(); //价格
				let sl = $("#petnum").text(); //宠物数量
				let day = $("#dd").text(); //寄养天数
				let zjg = jg * sl * day; //总金额
				$("#order_account").text(zjg);
			}
			//点击插入订单信息
			function dz() {
				let lxr = $("input[name=contacts]").val(); //客户
				let lxdh = $("input[name=contact_tel]").val(); //客户电话
				$(".lxr").text(lxr);
				$(".lxdh").text(lxdh);
				let psid = $("#psid").val(); //店铺编号	
				let oname = ""; //订单名称
				let time = new Date();
				let orderid = "Lj" + time.getTime(); //订单号
				// alert(orderid);
				// alert(upids);
				let num = $("#petnum").text(); //宠物数量
				let start = $(".today").text(); //开始寄养
				let end = $("#jiyangtianshu").text(); //结束寄养
				let remark = $("#bz").val(); //备注
				let moneys = $("#order_account").text(); //总金额		
				$(".price_class").text(moneys+".00");
				$("#ordernum").text(orderid);
				getPromise('http://localhost:80/ct/onepetshop', {
					"psid": psid
				}).then(function(r) {
					$(".psaddress").text(r.psname); //店铺名称
					$("#baidumap").text(r.psaddress); //店铺地址
					oname = r.psname + "为" + num + "只宠物申请的寄养服务";
					$("#itemname").text(oname);
					return getPromise('http://localhost:80/ct/addorder', {
						"psid": psid,
						"num": num,
						"start": start,
						"end": end,
						"remark": remark,
						"moneys": moneys,
						"oname": oname,
						"orderid": orderid,
						"upids": upids.join(',')
					});
				});

                //循环遍历upids 将寄养宠物信息显示
				for (var i = 0; i < upids.length; i++) {
					$.post('http://localhost:80/ct/petdetail', {
						"upid": upids[i]
					}, function(r) {
						let ps = "<p>" +
							"<div class='media'>" +
							"<div class='media-left' style='float: left;'>" +
							"<a href='javascript:;'><img class='thumbnail media-object' style='width: 50px;height:50px;' src='../images/" +
							r.up_file + "' alt='" + r.upname + "'></a>" +
							"</div>" +
							"<div class='petinfo' style='float: left;'>" +
							"<p><span>" + r.upname + "</span><small class='text-info'>母</small></p>" +
							"<p><span class='price_class'>生日：<span>" + r.upborndate + "</span></span></p>" +
							"</div>" +
							"</div>" +
							"</p>";
						$(".petinfoshow").append(ps);
					}, "json");

					$.post('http://localhost:80/ct/updatestatus', {
						"upid": upids[i],
						"status": 3
					}, function(r) {}, "json");
				}



			}
		
		</script>

	</body>
</html>